/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class TagLookupRequest
    {
    
        private List<String> tagNameField;

        private String customerIdField;

        private Decimal? tagPageField;

        private Decimal? countField;

        private String tagSortField;

        private List<String> responseGroupField;


        /// <summary>
        /// Gets and sets the TagName property.
        /// </summary>
        [XmlElementAttribute(ElementName = "TagName")]
        public List<String> TagName
        {
            get
            {
                if (this.tagNameField == null)
                {
                    this.tagNameField = new List<String>();
                }
                return this.tagNameField;
            }
            set { this.tagNameField =  value; }
        }



        /// <summary>
        /// Sets the TagName property
        /// </summary>
        /// <param name="list">TagName property</param>
        /// <returns>this instance</returns>
        public TagLookupRequest WithTagName(params String[] list)
        {
            foreach (String item in list)
            {
                TagName.Add(item);
            }
            return this;
        }          
 


        /// <summary>
        /// Checks of TagName property is set
        /// </summary>
        /// <returns>true if TagName property is set</returns>
        public Boolean IsSetTagName()
        {
            return (TagName.Count > 0);
        }




        /// <summary>
        /// Gets and sets the CustomerId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "CustomerId")]
        public String CustomerId
        {
            get { return this.customerIdField ; }
            set { this.customerIdField= value; }
        }



        /// <summary>
        /// Sets the CustomerId property
        /// </summary>
        /// <param name="customerId">CustomerId property</param>
        /// <returns>this instance</returns>
        public TagLookupRequest WithCustomerId(String customerId)
        {
            this.customerIdField = customerId;
            return this;
        }



        /// <summary>
        /// Checks if CustomerId property is set
        /// </summary>
        /// <returns>true if CustomerId property is set</returns>
        public Boolean IsSetCustomerId()
        {
            return  this.customerIdField != null;

        }


        /// <summary>
        /// Gets and sets the TagPage property.
        /// </summary>
        [XmlElementAttribute(ElementName = "TagPage")]
        public Decimal TagPage
        {
            get { return this.tagPageField.GetValueOrDefault() ; }
            set { this.tagPageField= value; }
        }



        /// <summary>
        /// Sets the TagPage property
        /// </summary>
        /// <param name="tagPage">TagPage property</param>
        /// <returns>this instance</returns>
        public TagLookupRequest WithTagPage(Decimal tagPage)
        {
            this.tagPageField = tagPage;
            return this;
        }



        /// <summary>
        /// Checks if TagPage property is set
        /// </summary>
        /// <returns>true if TagPage property is set</returns>
        public Boolean IsSetTagPage()
        {
            return  this.tagPageField != null;

        }


        /// <summary>
        /// Gets and sets the Count property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Count")]
        public Decimal Count
        {
            get { return this.countField.GetValueOrDefault() ; }
            set { this.countField= value; }
        }



        /// <summary>
        /// Sets the Count property
        /// </summary>
        /// <param name="count">Count property</param>
        /// <returns>this instance</returns>
        public TagLookupRequest WithCount(Decimal count)
        {
            this.countField = count;
            return this;
        }



        /// <summary>
        /// Checks if Count property is set
        /// </summary>
        /// <returns>true if Count property is set</returns>
        public Boolean IsSetCount()
        {
            return  this.countField != null;

        }


        /// <summary>
        /// Gets and sets the TagSort property.
        /// </summary>
        [XmlElementAttribute(ElementName = "TagSort")]
        public String TagSort
        {
            get { return this.tagSortField ; }
            set { this.tagSortField= value; }
        }



        /// <summary>
        /// Sets the TagSort property
        /// </summary>
        /// <param name="tagSort">TagSort property</param>
        /// <returns>this instance</returns>
        public TagLookupRequest WithTagSort(String tagSort)
        {
            this.tagSortField = tagSort;
            return this;
        }



        /// <summary>
        /// Checks if TagSort property is set
        /// </summary>
        /// <returns>true if TagSort property is set</returns>
        public Boolean IsSetTagSort()
        {
            return  this.tagSortField != null;

        }


        /// <summary>
        /// Gets and sets the ResponseGroup property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ResponseGroup")]
        public List<String> ResponseGroup
        {
            get
            {
                if (this.responseGroupField == null)
                {
                    this.responseGroupField = new List<String>();
                }
                return this.responseGroupField;
            }
            set { this.responseGroupField =  value; }
        }



        /// <summary>
        /// Sets the ResponseGroup property
        /// </summary>
        /// <param name="list">ResponseGroup property</param>
        /// <returns>this instance</returns>
        public TagLookupRequest WithResponseGroup(params String[] list)
        {
            foreach (String item in list)
            {
                ResponseGroup.Add(item);
            }
            return this;
        }          
 


        /// <summary>
        /// Checks of ResponseGroup property is set
        /// </summary>
        /// <returns>true if ResponseGroup property is set</returns>
        public Boolean IsSetResponseGroup()
        {
            return (ResponseGroup.Count > 0);
        }






        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            List<String> tagNameList  =  this.TagName;
            foreach (String tagName in tagNameList) { 
                xml.Append("<TagName>");
                xml.Append(EscapeXML(tagName));
                xml.Append("</TagName>");
            }	
            if (IsSetCustomerId()) {
                xml.Append("<CustomerId>");
                xml.Append(EscapeXML(this.CustomerId));
                xml.Append("</CustomerId>");
            }
            if (IsSetTagPage()) {
                xml.Append("<TagPage>");
                xml.Append(this.TagPage);
                xml.Append("</TagPage>");
            }
            if (IsSetCount()) {
                xml.Append("<Count>");
                xml.Append(this.Count);
                xml.Append("</Count>");
            }
            if (IsSetTagSort()) {
                xml.Append("<TagSort>");
                xml.Append(EscapeXML(this.TagSort));
                xml.Append("</TagSort>");
            }
            List<String> responseGroupList  =  this.ResponseGroup;
            foreach (String responseGroup in responseGroupList) { 
                xml.Append("<ResponseGroup>");
                xml.Append(responseGroup);
                xml.Append("</ResponseGroup>");
            }	
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}